<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>个人页面</title>
  <script src="https://cdn.jsdelivr.net/npm/babel-polyfill/dist/polyfill.min.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/jquery"></script>
  <script src="__PUBLIC__/node_modules/bootstrap/dist/js/bootstrap.min.js"></script>
  <script src="__PUBLIC__/node_modules/datatables/media/js/jquery.dataTables.min.js"></script>
  <link rel="stylesheet" href="__PUBLIC__/node_modules/bootstrap/dist/css/bootstrap.min.css">
  <link rel="stylesheet" href="__PUBLIC__/style/manage.css">
  <link rel="stylesheet" href="__PUBLIC__/style/me.css">
  <link rel="stylesheet" href="__PUBLIC__/style/me_qr.css">
  <style>
    .inori_center {
      margin: 0 auto;
      position: relative;
    }
    .inori_text-left {
       position: absolute;
       top: 50%;
       left: 65%;
       width: 15rem;
    }
  </style>
</head>
<body style='min-width:1040px;'>
  <!-- 隐藏功能元素区 -->
  <div class="hidden_form">
    <form autocomplete="off" action="__PUBLIC__/search" method="post" id = 'hidden_form'></form>
    <input type="hidden" name="ajax_base" id="ajax_base" value="{:U('Manageme/my_ajax')}">
  </div>
  <!-- end 隐藏功能元素区 -->

  <div class="container-fluid">
    <!--
      {$Think.session.user.ck_aj} =1 允许按揭员 0 不允许
      {$Think.session.user.ck_qudao} =1 允许显示 0 不允许
      {$Think.session.user.ck_fenxiao} =1 允许分销 0 不允许
     -->
    <div class="col-xs-12" style="height:5px;"></div>
    <div class="col-xs-11 col-xs-offset-1">
      <!-- Nav tabs -->
      <iframe src="{:U('me')}?local=qrcode" frameborder="0" style="width:100%;"></iframe>
    </div>

    <div class="main">
      <!-- logo 区域 -->
      <div class="logo_img">
        <if condition="$Think.session.user.login_img neq null">
        <span><img src="__ROOT__/{$Think.session.user.login_img}" alt="LOGO"></span>
        <else/>
        <span><img src="__PUBLIC__/images/dengluye/u5.png" alt="u5"></span>
        </if>
        <br>
        <span>{$Think.session.user.u_name}</span>
      </div>
      <!-- end logo 区域 -->

      <div style="height:4rem;width:100%;"></div>
      <if condition='$Think.session.user.ck_qudao eq 1'>
      <!-- 有渠道的时候 主要内容 -->
      <div class="col-xs-3" id='qudao_ok'>
        <p class="text-right">此二维码只适用于<span class="blue">公司渠道</span>注册</p>
      </div>
      <div class="col-xs-3 border_right">
        <div class="title"><span class="blue">公司渠道</span>注册二维码</div>
        <div class="title">

          <select name="qudao_id" id="qudao_name" class="qudao_select" style="margin-bottom:.5rem;line-height:2rem;height:2rem;">
              <!-- 这里填写可选公司渠道 -->
              <!-- 用户选择后会发出ajax获取二维码 -->

            <if condition='$list'>
              <option value="00" style="text-align:center;" selected>请选择您的公司渠道</option>
              <volist name='list' id ='vo'>
                <option value="{$vo.qudao_id}" style="text-align:center;">{$vo.qudao_name}</option>
              </volist>
            <else/><option value="00" style="text-align:center;" selected>请选择您的公司渠道</option>
            </if>

            </select>
        </div>
        <div class="qrcode"><img src="__PUBLIC__/images/5_0/u107.jpg" alt="u107" id="qudao_qr_code_img"></div>
      </div>
      <div class="col-xs-3">
        <div class="title"><span class="red">业务员</span>注册二维码</div>
        <div class="title" style='margin-bottom:.5rem;line-height:2rem;height:2rem;visibility: hidden;'><select name="" id="" class="qudao_select"></select></div>
        <div class="qrcode"><img src="__PUBLIC__/images/5_0/u107.jpg" alt="u107" id="yewu_qr_code_img"></div>
      </div>
      <div class="col-xs-3">
        <p class="text-left">此二维码只适用于公司直属<span class="red">业务员</span>注册</p>
      </div>
      <!-- end 有渠道的时候 主要内容 -->
      <elseif condition='$Think.session.user.ck_qudao eq 0'/>
      <!-- 没有渠道的时候 主要内容 -->
      <div class="row" style='clear:both;' id='qudao_notallow'>
        <div class="inori_center">
          <div class="title"><span class="red">业务员</span>注册二维码</div>
        <div class="title" style='margin-bottom:.5rem;line-height:2rem;height:2rem;visibility: hidden;'><select name="" id="" class="qudao_select"></select></div>
        <div class="qrcode"><img src="__PUBLIC__/images/5_0/u107.jpg" alt="u107" id="yewu_qr_code_img"></div>
        </div>
      </div>
      <!-- end 没有渠道的时候 主要内容 -->
    </if>
    </div>

    <!-- 页脚 -->
    <div class="col-xs-12">
      <div class="footer text-center"><p class="lead"><strong>深圳市東源匯信息科技有限公司</strong></p></div>
    </div>
    <!-- end 页脚 -->
  </div>

  <script>
    var url = $('#ajax_base').val()
    function getQr () {
      var name = $('#qudao_name').attr('name')
      var bank_value = $('#qudao_name').val()
      let bankData = {}
      bankData[name] = bank_value
      $.ajax(url, {
        method: 'POST',
        data: bankData,
        success: function (data) {
          console.log(data);
          if( data[0].code === 1) {
            let url = data[0].message
            $('#qudao_qr_code_img').attr('src', url)
          } else {
            alert('渠道二维码获取失败，请重新选择')
            $('#qudao_name').val('')
          }
        },
        error: function(){
          alert('二维码获取失败，请重新选择')
          $('#qudao_name').val('')
        }
      })
    }
    $(document).ready(function () {
      if(`{$Think.session.user.ck_qudao}` === '1') {
        $('#qudao_notallow').remove()
      } else {
        $('#qudao_ok').remove()
      }
      $('#qudao_name').on('change', getQr)

      // 获取业务员二维码
      $.ajax(url, {
        method: 'GET',
        data: '',
        success: function (data) {
          if( data[1].code === 1) {
            let url = data[1].message
            $('#yewu_qr_code_img').attr('src', url)
          } else {
            alert('业务员二维码获取失败，请检查网络后刷新页面')
          }
        },
        error: function(){
          alert('业务员二维码获取失败，请检查网络后刷新页面')
        }
      })
    })
  </script>
</body>
</html>